package com.xckj.cycling.view

import android.content.Context
import android.util.AttributeSet
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.just.agentweb.BaseIndicatorView
import com.xckj.cycling.R
import com.xckj.cycling.utils.DensityUtil

class WebProgressView @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null
) : BaseIndicatorView(context, attrs) {
    override fun offerLayoutParams(): LayoutParams {
        return LayoutParams(
            size,
            size, Gravity.CENTER
        )
    }

    private val imageView = ImageView(context)
    private val size = DensityUtil.dip2px(40f)

    init {
        addView(
            imageView, LayoutParams(
                size,
                size,
                Gravity.CENTER
            )
        )
        Glide.with(context).load(R.mipmap.loading).into(imageView)
    }

    override fun show() {
        super.show()
        visibility =View.VISIBLE
    }

    override fun hide() {
        super.hide()
        visibility = View.GONE
    }

}